/**
 * @description: 是否为Object
 * @category is
 * @param {unknown} val
 * @return {boolean}
 */
export const isObject = (val: unknown): val is Record<any, any> =>
  val !== null && typeof val === "object";

/**
 * @description 是否空对象
 * @param object
 * @category is
 * @example
 * ``` js
 * 1. isEmptyObject(null)
 * => Uncaught Error: param must be an object
 *
 * 2. isEmptyObject({ name: 'kuke' })
 * => false
 *
 * 3. isEmptyObject({})
 * => true
 * ```
 */
export const isEmptyObject = (object: Record<string, unknown>): boolean => {
  if (!isObject(object)) {
    throw new Error("param must be an object");
  }

  return Object.keys(object).length === 0;
};

/**
 * @description: 是否为Array
 * @category is
 * @param {unknown} val
 * @return {boolean}
 */
export const { isArray } = Array;
